﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ProductManager
{
    public partial class PathDatabase : Form
    {
        private MainForm _mainForm;
        public PathDatabase(MainForm mainForm)
        {
            InitializeComponent();
            _mainForm = mainForm;
        }

        private void PathDatabase_Load(object sender, EventArgs e)
        {

        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (DBAccess.OpenConnection(txtPath.Text.Trim()))
            {
                _mainForm.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Can't connect to Database!");
            }

        }

        private void txtPath_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                btnOk_Click(null, null);
        }

        private void PathDatabase_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }
    }
}
